// import jsonStringifySafe from 'json-stringify-safe';
import { toJS,observable } from 'mobx';
import initStore from './index';

class TestMobx {
    @observable testObj = {name:'jack'};
    @observable testArr = [{
      product:'bbo',
      id:'22'
    },{
      product:'bbo2',
      id:'223'
    }]

    initData(){
      this.testArr = [];
      this.testObj = {};
    }
}

const testMobx = new TestMobx();
/**
 Dehydrate (on server)
*/
export function dehydrate(store) {
  // convert store to json
  return JSON.stringify(toJS(testMobx, true)) ;
}

/**
  Rehydrate (on client)
*/
export function rehydrate() {
  // inject initial state into stores
  return initStore(window.__STATE);
}